package com.hbnu.system.controller;

import com.hbnu.system.core.base.Rest;
import com.hbnu.system.model.entity.ActivityType;
import com.hbnu.system.service.ActivityTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/ActivityType")
@Api(tags = "纵向-活动类型模块")
public class ActivityTypeController {
    @Autowired
    private ActivityTypeService activityTypeService;

    @ApiOperation("活动类型添加")
    @PostMapping("/addactivityType")
    public Rest<Boolean> addActivityType(@RequestBody ActivityType activityType){
        boolean add = activityTypeService.addActivityType(activityType);
        return add ? Rest.success():Rest.failed();
    }

    @ApiOperation("获取活动类型列表")
    @GetMapping("/getActivityType")
    public Rest<List<ActivityType>> getActivityTypes(){
        List<ActivityType> projectcateList = activityTypeService.getActivityTypeList();
        return Rest.success(projectcateList);
    }

    @ApiOperation("活动类型-修改")
    @PostMapping("/updateactivityType")
    public Rest<Boolean> updateActivityType(@RequestBody ActivityType activityType){
        boolean update = activityTypeService.updateActivityType(activityType);
        return update ? Rest.success() : Rest.failed();
    }

    @ApiOperation("活动类型-删除")
    @GetMapping("/deleteActivityType")
    public Rest<Boolean> deleteActivityType(String activityTypeID){
        boolean delete = activityTypeService.deleteActivityType(activityTypeID);
        return delete ? Rest.success() : Rest.failed();
    }

    //根据名字进行查询
    @ApiOperation("活动类型-根据名字查询")
    @GetMapping("/getActivityTypeByName")
    public Rest<List<ActivityType>> getActivityTypeByName(String activityTypeName){
        List<ActivityType> activityTypeList = activityTypeService.getActivityTypeListByName(activityTypeName);
        return Rest.success(activityTypeList);
    }


}
